﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TDNA
{
    public class CannonTower : BasicTower
    {
        public Cannon Cannon { get; set; }
        public List<BasicCreep> Creeps { get; set; }
        
        public CannonTower(tdVector2 p)
        {
            Pos = p;
            Creeps = new List<BasicCreep>();
            Range = 3;
            Cannon = new Cannon(500, 10);
        }

        public override void Update(ulong gameTime)
        {
            if (Cannon.Target == null)
            {
                if (Creeps.Count > 0) Cannon.Target = Creeps[0];
                Creeps.Clear();
            }
            else
            {
                Cannon.Fire();
                if (tdVector2.Dist(Pos, Cannon.Target.Pos) > Range || Cannon.Target.HP <= 0) Cannon.Target = null;
            }
            Cannon.Update(gameTime);
        }
 }
}
